import {mesTmMaterialBasePage as getMixinList} from "@/api/materials/tmMaterialBase";
import {mesTmMaterialBasePageJc as getMixinListJc} from "@/api/materials/tmMaterialBase";
import {getDict} from "@/api/common";

export const mixinDialog = {
  data() {
    return {
      mixinDialogVisible: false, //表格弹框隐藏显示
      mixinDialogVisibleJc: false, //表格弹框隐藏显示
      getMixinList, // 获取弹框数据接口
      getMixinListJc, // 获取弹框数据接口
      hasMixinFooter: true, // 是否需要底部按钮默认true
      mixinSearchDialog: {
        inline: true,
        formDesc: {
          materialType: {
            type: "select",
            label: '类型',
            prop: {
              text: "description",
              value: "value"
            },
            // Promise 对象
            options: async (data) => {
              const list = await getDict("tm_material_base")
              return list.data.result
            }
          },
          materialCode: {
            type: "input",
            label: '物料编号',
          },
          materialName: {
            type: "input",
            label: '物料名称',
          },
        },
      },
      mixinSearchDialogJc: {
        inline: true,
        formDesc: {
          materialType: {
            type: "select",
            label: '类型',
            options: [
              {
                value: "集采",
                text: "集采"
              },
              {
                value: "辅料",
                text: "辅料"
              },
            ],
            // Promise 对象
            // options: async (data) => {
            //   const list = await getDict("tm_material_base")
            //   return list.data.result
            // }
          },
          materialCode: {
            type: "input",
            label: '物料编号',
          },
          materialName: {
            type: "input",
            label: '物料名称',
          },
        },
      },
      mixinDialogColumn: [
        {
          type: "selection",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
        },
        {
          prop: "materialType",
          label: '类型',
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getDict("tm_material_base")
            return list.data.result;
          },
          showOverflowTooltip: true,
        },
        {
          prop: 'materialCode',
          label: '物料编号',
          showOverflowTooltip: true
        },
        {
          prop: 'materialName',
          label: '物料名称',
          showOverflowTooltip: true
        },
        {
          prop: "materialUnit",
          label: '物料单位',
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getDict("material_unit")
            return list.data.result;
          },
          showOverflowTooltip: true,
        },
      ],
    };
  },
};
